ImapFolderAgent: Emit a log message when creating an event or skipping it.

Akinori MUSHA 10 years ago
parent
commit
f3552ece2e
1 changed files with 6 additions and 1 deletions
  1. 6 1
      app/models/agents/imap_folder_agent.rb

+ 6 - 1
app/models/agents/imap_folder_agent.rb

@@ -230,6 +230,7 @@ module Agents
230 230
 
231 231
     def check
232 232
       each_unread_mail { |mail, notified|
233
+        message_id = mail.message_id
233 234
         body_parts = mail.body_parts(mime_types)
234 235
         matched_part = nil
235 236
         matches = {}
@@ -277,7 +278,9 @@ module Agents
277 278
           end
278 279
         } or next
279 280
 
280
-        unless notified.include?(mail.message_id)
281
+        if notified.include?(mail.message_id)
282
+          log 'Ignoring mail: %s (already notified)' % message_id
283
+        else
281 284
           matched_part ||= body_parts.first
282 285
 
283 286
           if matched_part
@@ -288,6 +291,8 @@ module Agents
288 291
             body = ''
289 292
           end
290 293
 
294
+          log 'Emitting an event for mail: %s' % message_id
295
+
291 296
           create_event :payload => {
292 297
             'folder' => mail.folder,
293 298
             'subject' => mail.subject,